<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
Ext.onReady(function(){   
    Ext.QuickTips.init();   
    Ext.form.Field.prototype.msgTarget="qtip";   
    var loginform = new Ext.form.FormPanel({     
        title:'用户登陆',   
        labelSeparator:":", 
        labelAlign:'right',
        //collapsible :true,   
        width:300,   
        height:200,   
        id:'login',   
        labelWidth: 80,   
        bodyStyle: 'padding:5px 5px 0 0',   
        border: false,   
        name:'login', 
        buttonAlign:'center',
        frame:true,   
        url: Ext.ContextPath+'/logon.do',
		waitMsg: '正在登录，请稍候！',
        items:[   
            new Ext.form.TextField({   
            fram:true,   
            fieldLabel:"用户ID",   
            name:'id',   
            allowBlank:false,   
            blankText:'用户名不能为空' 
        }),{   
            fieldLabel:"密码",   
            name:'password',   
            allowBlank:true,   
            inputType:'password',   
            blankText:'密码不能为空',  
            xtype:'textfield'
        },{
        	fieldLabel:"帐套",
        	name:'zhangt',   
            allowBlank:false,    
            xtype:'combo',
            typeAhead: true,
            hiddenName:'zhangt',
            editable :false,
            width:130,
    		triggerAction: 'all',
    		valueField: 'zhangt',
    		displayField: 'cAcc_Name',
    		store: new Ext.data.ArrayStore({
		        fields: ['zhangt','cAcc_Name'],
		        url:Ext.ContextPath+'/findZhangt.do',
		        autoLoad:false
	        })

        },{   
            fieldLabel:"操作日期",   
            name:'date', 
            editable :false,
            xtype:'datefield',
            value:new Date(),
            width:130,
            format:'Y-m-d'
             
        }],   
        keys:{   
            key: 13,   
            fn:login   
        },   
        buttons:[{   
            text:'提 交',   
            handler:login   
        },{   
            text:'重置',handler:function(){   
                loginform.form.reset();   
            }   
        }]   
    });   
    function login(button){  
    	button.setDisabled(true);
  		 loginform.getForm().submit({
		                    success: function(form, action){
		                    	location.href="index.jsp";
		                    },
		                    failure:function(form, action) {
		                    	switch (action.failureType) {
					            case Ext.form.Action.CLIENT_INVALID:
					                Ext.Msg.alert('错误', '发生错误，请刷新重试！');
					                break;
					            case Ext.form.Action.CONNECT_FAILURE:
					                Ext.Msg.alert('错误', '服务器连接错误，请联系管理员！');
					                break;
					            case Ext.form.Action.SERVER_INVALID:
					            	//alert(Ext.encode(action.result));
					                Ext.Msg.alert('错误', action.result.errors.msg);       	
					       		}
		                    }
		                });
		button.setDisabled(false);
    }   
    
    var win=new Ext.Window({
	    	layout:'fit',
	    	width:300,
	    	//height:300,
	    	frame:true,
	    	closable:false,
	    	maximizable:false,
	    	minimizable:false,
	    	//title:'上传文件',
	    	//x:50,
	    	//y:50,
	    	items:[loginform]	
	    });
	    
	    
	win.show();
       
});